package com.yanqu.road.server.cmd.activity.ghost;

import com.yanqu.road.entity.activity.ghost.config.GhostBossConfig;
import com.yanqu.road.entity.activity.ghost.config.GhostConfig;
import com.yanqu.road.pb.activity.GhostActivityProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.activity.ghost.GhostMgr;
import com.yanqu.road.server.pb.GhostPb;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.GameProtocol;

import java.util.List;

@Cmd(code = GameProtocol.S_GHOST_GET_CONFIG_FROM_CROSS, desc = "鬼市跨服获取boss配置")
public class GhostGetConfigFromCross extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        GhostActivityProto.CrossGhostGetBossConfigRespMsg reqMsg = GhostActivityProto.CrossGhostGetBossConfigRespMsg.parseFrom(packet.getBytes());
        List<Integer> typeList = reqMsg.getBossTypeListList();
        List<Long> hpList = reqMsg.getBossHpListList();

        GhostConfig ghostConfig = GhostMgr.getGhostConfig();
        if (ghostConfig != null) {
            GhostActivityProto.SyncBossConfigRespMsg.Builder builder = GhostActivityProto.SyncBossConfigRespMsg.newBuilder();
            for (GhostBossConfig bossConfig : ghostConfig.getBossConfigList()) {
                builder.addBossConfigList(GhostPb.parseGhostBossConfigMsg(bossConfig, typeList, hpList));
            }
            player.sendPacket(ClientProtocol.U_GHOST_SYNC_BOSS_CONFIG, builder);
        }
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
